Skip to content

perf(groebner): disable transparent huge pages in the F4 drivers - #11044

Merged
kim-em merged 4 commits into
mainfrom
groebner-driver-thp
Nov 9, 2026
Merged

kim-em merged 4 commits into
mainfrom
groebner-driver-thp

Conversation

@kim-em

@kim-em kim-em commented Nov 9, 2026 •

Copy link
Copy Markdown
Owner

This PR disables transparent huge pages for the standalone F4 driver processes (hexgroebner_compute, hexgroebner_sample and their full-initialization variants). The Lean runtime's allocator reserves its 1 GiB arena with MADV_HUGEPAGE. Under the common transparent_hugepage/defrag=madvise kernel policy, a first touch in that arena may compact memory synchronously and zero a whole 2 MiB page. On the shared host this was most of the startup cost (about 19M of 25M kernel instructions before any input is read) and added tens of percent to medium systems. Comparators using glibc malloc never request huge pages under the madvise policy.

A constructor in HexGroebner/ffi/driver_memory.c calls prctl(PR_SET_THP_DISABLE) before Lean module initialization. The kernel checks this flag at fault time for the whole process, so it also covers the arena that is already reserved. Setting HEX_GROEBNER_THP=1 keeps the inherited policy for comparisons. Only the driver executables link this object; library code never changes process state, and other platforms are unaffected. Outputs and logical counters are unchanged.

On the matched first-size selection (first primary size of all ten families in all three fields plus Eco-14/Eco-15 over F₂; 64 adjacent AB/BA pairs on one leased CPU against the frozen main build), the candidate-time ratio is 0.5947 and the process-time ratio 0.6643, with identical complete outputs and logical counters in every pair. Every family improves; the largest gains are on Katsura (0.42) and noon (0.44). How much huge-page compaction costs depends on host memory pressure, which also explains why earlier msolve sweeps of identical code ranged from 1.14 to 1.37. The matched held-out msolve sweep with this change gives an equal-family Hex/msolve process ratio of 1.0837 (dense-quadratic 1.42, positive-dimensional 0.95, sparse-structured 0.95), with 54 equal complete bases and no coverage loss. A full fixed-primary msolve sweep is still running and will be reported separately.

reports/bench-results/hexgroebner-thp.md is recomputed by scripts/bench/groebner_thp_report.py from the retained capsule f4-thp-64eddfd8f204 (four parts, manifest-checked). Scientific samples were collected manually on the shared host.

Continues #10987. Its correctness, finite-field coverage, parallel and fastest-open-source obligations remain open.

🤖 Prepared with Claude Code

Kim Morrison and others added 2 commits November 9, 2026 07:07
The Lean runtime allocator reserves its arena with MADV_HUGEPAGE. Under the
common defrag=madvise kernel policy, first touches may compact memory
synchronously and zero whole 2 MiB pages. The standalone driver executables
now disable transparent huge pages for their own process before module
initialization; HEX_GROEBNER_THP=1 keeps the inherited policy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Adjacent AB/BA comparison of the frozen main build and the THP-disabling
driver on the first-size selection (64 pairs, identical outputs and
counters), and the matched held-out msolve sweep. The report is
recomputed from the retained capsule.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kim-em
kim-em marked this pull request as ready for review November 9, 2026 09:29
Kim Morrison and others added 2 commits November 9, 2026 11:22
Derive the comparator revision from the campaign metadata, list families
without jointly solved pairs instead of dropping them, pass long arguments
to the variadic prctl, and state the constructor ordering precisely.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kim-em
kim-em enabled auto-merge (squash) November 9, 2026 11:27
@kim-em
kim-em merged commit 35e26ff into main Nov 9, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant